//
//  SportRecordGroup.m
//  CoolTennisBall
//
//  Created by Coollang on 16/8/17.
//  Copyright © 2016年 CoolLang. All rights reserved.
//

#import "SportRecordGroup.h"



@implementation SportRecordGroup


- (NSInteger)totalTimeInterval {
    
    _totalTimeInterval = 0;
    
    [self.sportRecordItems enumerateObjectsUsingBlock:^(SportRecordItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

        if (!obj.shouldShield) {
            _totalTimeInterval += obj.exerciseTimeInterval;
        }
    }];
    
    return _totalTimeInterval;
    
}

- (NSInteger)amountOfCount {
    
    _amountOfCount = 0;
    
    [self.sportRecordItems enumerateObjectsUsingBlock:^(SportRecordItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        if (!obj.shouldShield) {
            _amountOfCount += obj.amountOfCount;
        }
    
    }];
    
    return _amountOfCount;
}


- (void)setIsExpandGroup:(BOOL)isExpandGroup {
    _isExpandGroup = isExpandGroup;
    
    if (isExpandGroup) {
        self.headViewHeight = 96;
    }else {
        self.headViewHeight = 111;
    }
}




- (NSString *)yearText {
    
    NSString *string = [self yearAndMonth];
    return [string substringToIndex:4];
}


- (NSString *)monthText {
    NSString *string = [self yearAndMonth];
    
    return [string substringFromIndex:5];
}

@end
